#include <func.h>

typedef struct data
{
    pthread_mutex_t mutex;
    pthread_cond_t cond;
}data_t;
 
void* shuijiao(void*p)
{
    data_t *q=(data_t*)p;
    pthread_mutex_lock(&q->mutex);
    printf("i will wait\n");
    pthread_cond_wait(&q->cond,&q->mutex);
    pthread_mutex_unlock(&q->mutex);
    printf("i am awake\n");
}

int main()
{
    data_t *p;
    pthread_t d;
    int ret=pthread_mutex_init(&p->mutex,NULL);
    THREAD_ERR_CHECK(ret,"pthread_mutex_init");
    ret=pthread_cond_init(&p->cond,NULL);
    THREAD_ERR_CHECK(ret,"pthread_cond_init");
    ret=pthread_create(&d,NULL,shuijiao,(void*)p);
    THREAD_ERR_CHECK(ret,"pthread_create");
    printf("已经创建好了\n");
    sleep(1);
    pthread_cond_signal(&p->cond);
    printf("我把他叫醒了\n");
    sleep(1);
    ret=pthread_mutex_destroy(&p->mutex);
    THREAD_ERR_CHECK(ret,"pthread_mutex_destroy"); 
    return 0;
}